import http from "@/utils/request";
import model from "@/config/model";

export default {
  queryWithPage: {
    url: `/code-generator/v1.0/gen-table/query-with-page`,
    name: "代码生成-分页查询",
    post: async function (path, data) {
      let baseApi = `${model.API_URL}` + "/";
      return await http.post(baseApi + path + this.url, data);
    },
  },
  queryAll: {
    url: `/code-generator/v1.0/gen-table/query-all`,
    name: "代码生成-查询所有",
    get: async function (path) {
      let baseApi = `${model.API_URL}`;
      return await http.get(baseApi + path + this.url);
    },
  },
  queryColumnsByTableName: {
    url: `/code-generator/v1.0/gen-table/query-columns-by-table-name/`,
    name: "代码生成-查询表所有列",
    get: async function (path, data) {
      let baseApi = `${model.API_URL}`;
      return await http.get(baseApi + path + this.url + data);
    },
  },
  selectDbTables: {
    url: `/code-generator/v1.0/gen-table/select-db-tables`,
    name: "数据库表-分页查询",
    post: async function (path, data) {
      let baseApi = `${model.API_URL}` + "/";
      return await http.post(baseApi + path + this.url, data);
    },
  },
  importTable: {
    url: `/code-generator/v1.0/gen-table/import-table`,
    name: "代码生成-导入",
    post: async function (path, data, locale) {
      let baseApi = `${model.API_URL}` + "/";
      return await http.post(baseApi + path + this.url + "/" + locale, data);
    },
  },
  modify: {
    url: `/code-generator/v1.0/gen-table/modify`,
    name: "代码生成-修改",
    post: async function (path, data, locale) {
      let baseApi = `${model.API_URL}` + "/";
      return await http.post(baseApi + path + this.url + "/" + locale, data);
    },
  },
  queryByTableId: {
    url: `/code-generator/v1.0/gen-table/`,
    name: "数据库表-通过id查询",
    get: async function (path, data) {
      let baseApi = `${model.API_URL}` + "/";
      return await http.get(baseApi + path + this.url + data);
    },
  },
  previewCode: {
    url: `/code-generator/v1.0/gen-table/preview/`,
    name: "数据库表-预览",
    get: async function (path, data) {
      let baseApi = `${model.API_URL}` + "/";
      return await http.get(baseApi + path + this.url + data);
    },
  },
  synchDb: {
    url: `/code-generator/v1.0/gen-table/synch-db/`,
    name: "数据库表-同步",
    get: async function (path, data, locale) {
      let baseApi = `${model.API_URL}` + "/";
      return await http.get(baseApi + path + this.url + data + "/" + locale);
    },
  },
  batchGenCode: {
    url: `/code-generator/v1.0/gen-table/batch-gen-code`,
    name: "代码生成-批量生成",
    post: async function (path, data) {
      let baseApi = `${model.API_URL}` + "/";
      return await http.down(baseApi + path + this.url, data, {
        headers: {
          "Content-Type": "application/json;charset=UTF-8",
          exportFlag: "1",
          channelCode: "C01",
        },
        method: "post",
      });
    },
  },
  batchTureDelete: {
    url: `/code-generator/v1.0/gen-table/batch-true-delete`,
    name: "代码生成-批量删除",
    post: async function (path, data) {
      let baseApi = `${model.API_URL}` + "/";
      return await http.post(baseApi + path + this.url, data);
    },
  },
};
